package com.example.nonggo.bean;

import org.json.JSONObject;

import java.util.Calendar;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class AverageByDateDTO {
//    {"varietyName":"面粉","beginTime":1738641599950,"endTime":1741233599950,"pageSize":31}
    private String varietyName;
    private long beginTime;
    private long endTime;
    private int pageSize;

    public AverageByDateDTO() {
    }

    public AverageByDateDTO(String varietyName) {
        this.varietyName = varietyName;
//{"varietyName":"面粉","beginTime":1738641599950,"endTime":1741233599950,"pageSize":31}
        Calendar calendar = Calendar.getInstance();
        this.endTime = calendar.getTimeInMillis();
        calendar.add(Calendar.DAY_OF_YEAR, -30);
        this.beginTime = calendar.getTimeInMillis();
//        this.varietyName = "面粉";
//        this.beginTime= 1738641599950L;
//        this.endTime = 1741233599950L;
        this.pageSize = 31;
    }
    public RequestBody toRequestBody(){
        JSONObject j = new JSONObject();
        try {
           j.put("varietyName", varietyName);
//            j.put("beginTime", beginTime);
//            j.put("endTime", endTime);
            j.put("pageSize", pageSize);
        } catch (Exception ignore) {
        }
        return RequestBody.create(MediaType.parse("application/json; charset=utf-8"), j.toString());
    }
    public String getVarietyName() {
        return varietyName;
    }

    public void setVarietyName(String varietyName) {
        this.varietyName = varietyName;
    }

    public long getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(long beginTime) {
        this.beginTime = beginTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }


}
